// pages/component/people/peoperinfore.js
var CONFIG = require("../../../config/config.js");
var share = require("../../../utils/share.js");
Component({
      /**
       * 组件的属性列表
       */
        properties: {
        },

        /**
        * 组件的初始数据
        */
        data: {
            imgUrl:CONFIG.API_PIC,
            showfalse:false,
            id:'',
            index:'',
            recorddata:[],
        },

        /**
         * 组件的方法列表
         */
        methods: {
            showMyTips(data, nowPage){
                var that = this;
                if (Number(nowPage) <= 0) {
                    that.setData({
                        recorddata: data,
                        errcode: 1
                    })
                } else {
                    if (Number(data.length) > 0) {
                        that.setData({
                            recorddata: that.data.recorddata.concat(data),
                        })
                    } else {
                        that.setData({
                            recorddata: that.data.recorddata,
                        })
                    }
                }
            },
            // 点击写跟进
            gofollow(){
                var that = this;
                that.triggerEvent('gofollwe', '-1')
                  
            },
            closeclick(){
                var that = this;
                that.setData({
                    showfalse:false
                })
            },
            yesclick(){
                var that = this;
                wx.showLoading({
                    title: '加载中~',
                })
                var recorddata = that.data.recorddata;
                var index = that.data.index;
                var id = that.data.id;
                share.wxRequest('crmapi/user/delStuRecord', { id: id }, function (res) {
                    if (Number(res.data.errcode) == 0) {
                        recorddata.splice(index, 1);
                        that.setData({
                            recorddata: recorddata,
                            showfalse: false
                        })
                        that.triggerEvent('peoplerecode', '1')
                        wx.hideLoading();
                    } else {
                        wx.hideLoading();
                        wx.showToast({
                            title: res.data.msg,
                            icon: 'none'
                        })
                    }

                })
            },
            // 编辑
            editclick(e){
                var that = this;
                // console.log(e);
                var id = e.currentTarget.dataset.item.id;
                that.triggerEvent('gofollwe', id);
            },
            // 点击删除
            deleclick(e){
                var that = this;
                // console.log(e);
                
                var id = e.currentTarget.dataset.item.id;
                var index = e.currentTarget.dataset.index;
                that.setData({
                    id:id,
                    index:index,
                    showfalse: true
                })
                
            },
        }
})
